package com.synway.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

@Slf4j
public class SpiderHandler {
    public static AmqpTemplate rabbitTemplate;


    public static void spiderHandler(String rootPath, String pythonEnv, String py){
        log.info("mysql start...");
        try {
            String[] args2 = new String[]{pythonEnv, rootPath + py, "cd"};
            Process process = Runtime.getRuntime().exec(args2);
            StreamThread errorGobbler = new StreamThread(process.getErrorStream(),"Error");
            StreamThread outputGobbler = new StreamThread(process.getErrorStream(),"Output");
            errorGobbler.start();
            outputGobbler.start();
            process.waitFor();
            log.info("mysql end...");
            //通知mq爬虫结束

        } catch (IOException | InterruptedException e) {
            log.error("mysql error..." + e);
        }
    }



}
